#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
   @Author: 即将拥有人鱼线的yjw
   @Time: 2024/4/17 16:59
   @File: TA_test.py
   @desc:
"""
import random
from copy import copy


import threading
from multiprocessing import Process

from DataTest.databases import OracleUtil, MysqlUtil, OceanBaseUtil, PostgreSqlUtil, DaMengUtil
from DataTest.tabledata.commonData import randomInfo
from DataTest.tabledata.commonData.SQLMontage import montage_sql_value, get_sql_key, get_sql
from DataTest.tabledata.commonData.clientInfoTa import client_info_hsraw_ta, sql_source_list, \
    client_info_hsraw_ta_institution

startNum = 2180
endNum = 2190
init_date = 20241125
# db = MysqlUtil('root', 'root', '10.20.37.217', port=33061)
db = MysqlUtil('root', 'fxq5@123', '10.20.46.217', port=33061)
# db = MysqlUtil('root', 'root', '10.20.46.216', port=33061)
# db = MysqlUtil('root', 'DFLTdf87220bf0', '10.20.181.116', port=33061)
# db = MysqlUtil('tdsqlpcloud', 'admin@111', '10.20.249.156', port=15001)
# db = OceanBaseUtil('hsraw@oboracle#obtest','hsraw','10.20.192.107',2883)
# db = PostgreSqlUtil('postgresql','fxq123','10.20.37.112',server='hsrcm',port='5432')

# db = OracleUtil('hsraw','hsraw','10.20.154.134',server='bsaml')
pgdb = OracleUtil('hsraw','fxq5@123','10.20.37.111',server='bsaml')
# pgdb = OceanBaseUtil('hsraw@oboracle#obdemo','hsraw','10.20.194.171',2883)
# pgdb = PostgreSqlUtil('hsrcm_admin','ERTzxc@#$123','10.20.27.168',server='hsrcm_5',port='11345')
# db = OracleUtil('hsraw','hsraw','10.20.181.115',server='ORCL')
# pgdb = PostgreSqlUtil('postgresql','fxq123','10.20.37.112',server='hsrcm',port='5432')
# pgdb = DaMengUtil('SYSDBA','SYSDBA','10.20.194.78')
# pgdb = DaMengUtil('SYSDBA','SYSDBA','10.20.194.79')
# pgdb = OracleUtil('hsraw','fxq5@123','10.20.37.111',server='bsaml')


def insert_agencyinfo_his(taNo = 'ZX'):
    agency_list =['001 信银直销 0', '002 中国工商银行股份有限公司 1', '003 农行 1', '004 中国银行股份有限公司 1', '005 建行 1', '006 交行 1', '007 招商银行股份有限公司 1', '008 中信实业银行 1', '020 平安银行股份有限公司 1', '021 宁波银行股份有限公司 1', '163 腾安基金销售（深圳）有限公司 1', '227 数米网 1', '301 诺亚正行基金销售有限公司 1', '303 上海天天基金销售有限公司 1', '304 上海好买基金销售有限公司 1', '305 蚂蚁(杭州)基金销售有限公司 1', '307 浙江同花顺基金销售有限公司 1', '328 北京汇成基金销售有限公司 1', '348 上海万得基金销售有限公司 1', '362 上海基煜基金销售有限公司 1', '601 国泰君安证券股份有限公司 1', '624 华泰证券股份有限公司 1', '682 东方财富证券股份有限公司 1', '626 中信证券华南股份有限公司 1', 'CMS 招商场外 1', 'ZFB 支付宝 1']
    for agency in agency_list:
        agencyinfo = agency.split(' ')
        agencycode = agencyinfo[0]  # 销售商编号
        agencyname = agencyinfo[1]  # 销售商名称
        agencytype = agencyinfo[2]  # 销售商类型
        sql = f"INSERT INTO hsraw.taaml_n_agencyinfo_fund (c_tano,d_datadate,Agencycode,Agencyname,Agencyfullname,Headquartersaddress,PostalCode,Agencycontacts,Agencycontactnumber,AgencyFaxnumber,AgencyEMail,Agencybankcode,AgencyBankaccountnumber,Bankaccountname,Agencytype,AgencyregistrationDate,Sharedetailssupported,Sharecategorysupported,Maximumdiscountforsubscription,Maximumdiscountredemptionconv,Redemptionliquidationdays,Subscriptionclearingdays,Dividendclearingdays,Subscriptioninterestdays,Supportonesteptransferinto,Accountnumberpreallocation,Currentconfirmserialnumber,ReconciliationMethod,Subpaymentarrivaldateandmethod,issupportmultipletradeaccounts,Interfaceconfigurationversion,Interfacemode,Fundconversionconfirmationway,Subscriptionadvanceratio,Subscriptionadvanceproportion,Vendororganizationcategory,Remark) VALUES('{taNo}',20240826,'{agencycode}','{agencyname}','{agencyname}',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'{agencytype}',NULL,'1','0',0.0000,0.0000,0,0,0,0,'1','0',28229,'2','0','1','402','0','1',0.0000,0.0000,NULL,'2')"
        db.execsql(sql)
        #pgdb.execsql(sql)


def insert_agencyinfo(taNo = 'ZX'):
    Agencycode = random.randint(100, 999)
    sql = f"INSERT INTO hsraw.taaml_n_agencyinfo_fund (c_tano,d_datadate,Agencycode,Agencyname,Agencyfullname,Headquartersaddress,PostalCode,Agencycontacts,Agencycontactnumber,AgencyFaxnumber,AgencyEMail,Agencybankcode,AgencyBankaccountnumber,Bankaccountname,Agencytype,AgencyregistrationDate,Sharedetailssupported,Sharecategorysupported,Maximumdiscountforsubscription,Maximumdiscountredemptionconv,Redemptionliquidationdays,Subscriptionclearingdays,Dividendclearingdays,Subscriptioninterestdays,Supportonesteptransferinto,Accountnumberpreallocation,Currentconfirmserialnumber,ReconciliationMethod,Subpaymentarrivaldateandmethod,issupportmultipletradeaccounts,Interfaceconfigurationversion,Interfacemode,Fundconversionconfirmationway,Subscriptionadvanceratio,Subscriptionadvanceproportion,Vendororganizationcategory,Remark) VALUES('{taNo}',20240826,'{Agencycode}','测试销售商{Agencycode}','测试销售商{Agencycode}',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'1',NULL,'1','0',0.0000,0.0000,0,0,0,0,'1','0',28229,'2','0','1','402','0','1',0.0000,0.0000,NULL,'2')"
    db.execsql(sql)
    #pgdb.execsql(sql)


def insert_fundinfo(taNo = 'ZX'):
    fundcode = random.randint(10000, 99999)
    fundname = f'测试产品{fundcode}'
    sql = f"INSERT INTO hsraw.taaml_n_fundinfo_fund (c_tano,d_datadate,fundcode,fundname,currencytype,f_parvalue,f_issueprice,d_issuedate,d_setupdate,c_managername,c_custodianno,c_custodianname,f_maximumraisedamount,f_minimumraisedamount,f_lowshareterm,f_fundsubscriptionperiod,f_fundclosureperiod,f_accountsopenedminnumber,f_toofewcustomerdeadlines,f_proportionoversubscription,c_fundcharacteristics,c_fundlateststatus,c_subscriptionmode,c_duration,c_shareclassification,c_fundissuingmethod,f_actualfundraisedamount,f_fundestablishmentconfirepro,c_raisingfailuredate,c_ratecalculationmethod,c_rateconsolidationmethod,c_costcalculationmethod,c_partialconfirmation,c_defaultdividendmethod,c_subscriptioninterestmethod,f_redemptionfeefundassetspro,f_conversionfeefundassetspro,f_managementfeeaccrualpro,c_property,f_cumulativeunitdividend,d_maturitydate,c_isinconversionoffer,c_productclassification,c_decimalprecisionnetvalue,d_contractenddate,d_fundcontracteffectivedate,d_issueenddate,c_ismandatoryinvestmentfund,c_issupportyuebao,c_isshorttermfinancialfund,c_fundfullenglishname,f_TNconfirmationdays,c_risklevel,c_exportfundabbreviation,c_fundauxiliarystatus,c_managercode,c_incomecarryforwardfrequency,c_iscarriedforward,d_monthlycashingdate,c_officialcode,exchangeflag,redemptionclosedmethod,Lengthofclosureperiod,closedperiodunit,masterfundcode,sidepocketidentification,f_maxredeem,fundfullname,remark) VALUES('{taNo}',20240826,'{fundcode}','{fundname}','156',1.00000000,1.00000000,'20220505','20220509',NULL,'007','招商银行',5000000000.00,10000000.00,0,1,0,1,0,0.00000000,NULL,'1','0',60,'A','0',50000000.00,1.00000000,NULL,'1','0',NULL,'1','1','1',0.00000000,0.00000000,0.0150,'9',0.00000000,'20270507','1','2',4,NULL,NULL,'20220506','0','0','0',NULL,1,'4',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,NULL,'测试产品{fundcode}                            0 0000000000')"
    print(sql +';')
    db.execsql(sql)
    #pgdb.execsql(sql)

    select_sql = 'select product_code,product_name  from hsfund.fnd_fund_info'
    result = pgdb.execsql(select_sql)
    print(result)
    result.append({'product_code':fundcode,'product_name':fundname})
    for temp_list in result:
        temp = {k.lower(): v for k, v in temp_list.items()}
        fundcode = temp.get('product_code')
        fundname = temp.get('product_name')
        nev = round(random.random(), 4) + 1  #随机生成4位小数
        totalfund = random.randint(10000, 9999999)+ round(random.random(), 2)#基金总份额
        totalall = random.randint(1000, 999999)+ round(random.random(), 2)#基金总份额
        totalred = random.randint(1000, 999999)+ round(random.random(), 2)#基金总份额
        totalnet = round(totalfund * nev,2)  #基金总净值
        growList = [0.010645,0.011274,0.002689,0.011427,0.011139,0.005912,-0.058360,0.015422,-0.018780,0,0.004111,0.010069]
        grow = random.choice(growList)
        sql = f"INSERT INTO hsraw.taaml_n_fundday_fund (c_tano,d_datadate,c_raisetype,fundcode,fundname,nav,totalfundvol,totalallotvol,totalredeemvol,fundstatus,alternationdate,sharecategory,accumulatednet,yesterdayfundincome,tenthousandfundincome,yield,hugeredemptionmark,largeredemptionratio,transferoutconfirmproportion,oversubscriptionsign,oversubscriptionproportion,totalnetfundvalue,salesservicefee,networthgrowthrate,fixedinvestmentstatus,transitionstate,transfertubestatus,mergesplitstatus,pensionproductregistrationno,exchangerate,undistributedincome,fofexternalinvestproportion,documentnetworthdate,masterfundcode,sidepocketidentification,nextopeningperiodenddate,remark) VALUES('{taNo}',20240826,' ','{fundcode}','{fundname}',{nev},{totalfund},{totalall},{totalred},'0','20220815','A',{nev},0.00,0.00000,0.000000,'0',1.00000000,1.00000000,'0',1.00000000,{totalnet},0.00,{grow},NULL,NULL,NULL,NULL,NULL,0.0000,0.00,NULL,NULL,NULL,NULL,NULL,'000000020220815')"
        print(sql + ';')
        if len(f"{fundcode}")<= 8:
            db.execsql(sql)
            #pgdb.execsql(sql)


def exchangerate(taNo = 'ZX'):
    sql = f"INSERT INTO hsraw.taaml_n_exchangerate_fund (c_tano,d_datadate,d_exratedate,c_currencycode,c_markcurrency,f_exrate) VALUES('{taNo}',20240826,20240826,'156','156',1.0000)"
    db.execsql(sql)
    #pgdb.execsql(sql)
    sql = f"INSERT INTO hsraw.taaml_n_exchangerate_fund (c_tano,d_datadate,d_exratedate,c_currencycode,c_markcurrency,f_exrate) VALUES('{taNo}',20240826,20240826,'344','344',0.9243 )"
    db.execsql(sql)
    #pgdb.execsql(sql)
    sql = f"INSERT INTO hsraw.taaml_n_exchangerate_fund (c_tano,d_datadate,d_exratedate,c_currencycode,c_markcurrency,f_exrate) VALUES('{taNo}',20240826,20240826,'840','840',7.2397)"
    db.execsql(sql)
    #pgdb.execsql(sql)


def ta_test_person(startNum,custNum):
    #生成个人数据
    for i in range(startNum,custNum):
        str = 'ZX0000000000'
        replacement = f"{i}"
        TAACCOUNTID = str[:-len(replacement)] + replacement
        print(TAACCOUNTID)
        sql_list = client_info_hsraw_ta(TAACCOUNTID, init_date)
        list_source = sql_source_list()
        transactioncfmdate = transactiondate = TransactionDate = '20240826'
        appsheetserialno = AppSheetSerialNo = f"{TransactionDate}{randomInfo.get_random_number(6)}"
        businesscode = BusinessCode = random.choice(['120','122','124','126'])
        applicationvol = ApplicationVol ='0' #基金份额数
        applicationamount = ApplicationAmount = randomInfo.get_random_number(random.choice([3,4, 5, 6, 7]))#基金金额
        currencytype = CurrencyType = '156'
        targetsharetype = TargetShareType = 'A' #份额类型
        index = random.randint(1, 100)
        Processingstatus = '1'
        taconfirmationnumber  = f"{AppSheetSerialNo}{randomInfo.get_random_number(6)}{randomInfo.get_random_number(4)}"
        if index < 10:
            Processingstatus = '0'
            applicationamount = ApplicationAmount = applicationamount + round(random.random(), 2)
        sql_list.update({'taconfirmationnumber':taconfirmationnumber,'TransactionDate':TransactionDate,'AppSheetSerialNo':AppSheetSerialNo,'BusinessCode':BusinessCode,'ApplicationVol':ApplicationVol,'ApplicationAmount':ApplicationAmount,
                            'CurrencyType':CurrencyType,'TargetShareType':TargetShareType,'Processingstatus':Processingstatus,'applicationvol':applicationvol,'applicationamount':applicationamount,'appsheetserialno':appsheetserialno,
                         'transactioncfmdate':transactioncfmdate,'transactiondate':transactiondate,'businesscode':businesscode,'currencytype':currencytype,'targetsharetype':targetsharetype})
        confirmedamount = ApplicationAmount * 0.95
        confirmedvol = confirmedamount / 1.5  # 后续再捞基金净值算份额
        sharetype = 'A'
        sql_list.update({'confirmedamount': confirmedamount, 'confirmedvol': confirmedvol,'sharetype':sharetype})
        dailynewrevenue = randomInfo.get_random_number(4) #每日新增受益
        currentfundshare = randomInfo.get_random_number(5)# '当前基金份额',
        freezefundshares = randomInfo.get_random_number(4)#冻结基金份额'
        sql_list.update({'dailynewrevenue': dailynewrevenue, 'currentfundshare': currentfundshare,'freezefundshares':freezefundshares})

        for temp in list_source:
             sql  = temp.get('key') + montage_sql_value(table=temp.get('value'), sql_list=sql_list)
             print(sql +';')
             db.execsql(sql)
             #pgdb.execsql(sql)


        #执行x1数据
        for j in range(1):
            sql_list_copy = copy(sql_list)
            deletekey = random.choice(['accountabbr','sex','mobiletelno','educationlevel','individualorinstitution','certificatetype'])
            sql_list_copy.pop(deletekey)
            appsheetserialno =f"{init_date}{random.randint(10000, 99999)}{random.randint(10000, 99999)}{random.randint(10000, 99999)}"
            transactiondate = f"{init_date}"
            transactiontime = f"{random.randint(10000, 19999)}"
            sql_list_copy.update({"appsheetserialno":appsheetserialno,"transactiondate":transactiondate,"transactiontime":transactiontime})
            key_amlx1currents = get_sql_key(table='taaml_n_amlx1currents_fund')
            value_amlx1currents = get_sql(table='taaml_n_amlx1currents_fund')
            sql = key_amlx1currents + montage_sql_value(table=value_amlx1currents, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)
            key = get_sql_key(table='taaml_n_amlx1info_fund')
            value = get_sql(table='taaml_n_amlx1info_fund')
            sql = key + montage_sql_value(table=value, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)


        #执行交易数据
        for k in range(10):
            sql_list_copy = copy(sql_list)
            transactioncfmdate = transactiondate = TransactionDate = '20240826'
            appsheetserialno = AppSheetSerialNo = f"{TransactionDate}{randomInfo.get_random_number(6)}"
            businesscode = BusinessCode = random.choice(['120', '122', '124', '126'])
            applicationvol = ApplicationVol = '0'  # 基金份额数
            applicationamount = ApplicationAmount = randomInfo.get_random_number(random.choice([3, 4, 5, 6, 7]))  # 基金金额
            currencytype = CurrencyType = '156'
            targetsharetype = TargetShareType = 'A'  # 份额类型
            index = random.randint(1, 100)
            Processingstatus = '1'
            taconfirmationnumber = f"{AppSheetSerialNo}{randomInfo.get_random_number(6)}{randomInfo.get_random_number(4)}"
            if index < 10:
                Processingstatus = '0'
                applicationamount = ApplicationAmount = applicationamount + round(random.random(), 2)
            sql_list_copy.update({'taconfirmationnumber': taconfirmationnumber, 'TransactionDate': TransactionDate,
                             'c_appsheetserialno':AppSheetSerialNo, 'AppSheetSerialNo': AppSheetSerialNo, 'BusinessCode': BusinessCode,
                             'ApplicationVol': ApplicationVol, 'ApplicationAmount': ApplicationAmount,
                             'CurrencyType': CurrencyType, 'TargetShareType': TargetShareType,
                             'Processingstatus': Processingstatus, 'applicationvol': applicationvol,
                             'applicationamount': applicationamount, 'appsheetserialno': appsheetserialno,
                             'transactioncfmdate': transactioncfmdate, 'transactiondate': transactiondate,
                             'businesscode': businesscode, 'currencytype': currencytype,
                             'targetsharetype': targetsharetype})
            confirmedamount = ApplicationAmount * 0.95
            confirmedvol = confirmedamount / 1.5  # 后续再捞基金净值算份额
            sharetype = 'A'
            sql_list_copy.update({'confirmedamount': confirmedamount, 'confirmedvol': confirmedvol, 'sharetype': sharetype})
            key_request = get_sql_key(table='taaml_n_request_fund')
            value_request = get_sql(table='taaml_n_request_fund')
            sql = key_request + montage_sql_value(table=value_request, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)
            key = get_sql_key(table='taaml_n_confirm_fund')
            value = get_sql(table='taaml_n_confirm_fund')
            sql = key + montage_sql_value(table=value, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)


def ta_test_institution(startNum,custNum):
    # 生成机构数据
    for i in range(startNum, custNum):
        str = 'ZXAG00000000'
        replacement = f"{i}"
        TAACCOUNTID = str[:-len(replacement)] + replacement
        print(TAACCOUNTID)
        sql_list = client_info_hsraw_ta_institution(TAACCOUNTID, init_date)
        list_source = sql_source_list()
        transactioncfmdate = transactiondate = TransactionDate = '20240826'
        appsheetserialno = AppSheetSerialNo = f"{TransactionDate}{randomInfo.get_random_number(6)}"
        businesscode = BusinessCode = random.choice(['120', '122', '124', '126'])
        applicationvol = ApplicationVol = '0'  # 基金份额数
        applicationamount = ApplicationAmount = randomInfo.get_random_number(random.choice([3, 4, 5, 6, 7]))  # 基金金额
        currencytype = CurrencyType = '156'
        targetsharetype = TargetShareType = 'A'  # 份额类型
        index = random.randint(1, 100)
        Processingstatus = '1'
        taconfirmationnumber = f"{AppSheetSerialNo}{randomInfo.get_random_number(6)}{randomInfo.get_random_number(4)}"
        if index < 10:
            Processingstatus = '0'
            applicationamount = ApplicationAmount = applicationamount + round(random.random(), 2)
        sql_list.update({'taconfirmationnumber': taconfirmationnumber, 'TransactionDate': TransactionDate,
                         'c_appsheetserialno':AppSheetSerialNo,'AppSheetSerialNo': AppSheetSerialNo, 'BusinessCode': BusinessCode,
                         'ApplicationVol': ApplicationVol, 'ApplicationAmount': ApplicationAmount,
                         'CurrencyType': CurrencyType, 'TargetShareType': TargetShareType,
                         'Processingstatus': Processingstatus, 'applicationvol': applicationvol,
                         'applicationamount': applicationamount, 'appsheetserialno': appsheetserialno,
                         'transactioncfmdate': transactioncfmdate, 'transactiondate': transactiondate,
                         'businesscode': businesscode, 'currencytype': currencytype,
                         'targetsharetype': targetsharetype})
        confirmedamount = ApplicationAmount * 0.95
        confirmedvol =confirmedamount / 1.5  #后续再捞基金净值算份额
        sharetype ='A'
        sql_list.update({'confirmedamount':confirmedamount,'confirmedvol':confirmedvol,'sharetype':sharetype})
        dailynewrevenue = randomInfo.get_random_number(4)  # 每日新增受益
        currentfundshare = randomInfo.get_random_number(5)  # '当前基金份额',
        freezefundshares = randomInfo.get_random_number(4)  # 冻结基金份额'
        sql_list.update({'dailynewrevenue': dailynewrevenue, 'currentfundshare': currentfundshare,
                         'freezefundshares': freezefundshares})
        for temp in list_source:
            sql = temp.get('key') + montage_sql_value(table=temp.get('value'), sql_list=sql_list)
            print(sql+ ';')
            db.execsql(sql)
            #pgdb.execsql(sql)

        for j in range(1):
            sql_list_copy = copy(sql_list)
            deletekey = random.choice(['instrepr', 'transactor', 'controlholder', 'actualcontroller', 'beneowner', 'taxno', 'orgno','vocation'])
            sql_list_copy.pop(deletekey)
            appsheetserialno = f"{init_date}{random.randint(10000, 99999)}{random.randint(10000, 99999)}{random.randint(10000, 99999)}"
            transactiondate = f"{init_date}"
            transactiontime = f"{random.randint(10000, 19999)}"
            sql_list_copy.update({"appsheetserialno": appsheetserialno, "transactiondate": transactiondate,"transactiontime": transactiontime})
            key = get_sql_key(table='taaml_n_amlx3currents_fund')
            value = get_sql(table='taaml_n_amlx3currents_fund')
            sql = key + montage_sql_value(table=value, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)
            key = get_sql_key(table='taaml_n_amlx3info_fund')
            value = get_sql(table='taaml_n_amlx3info_fund')
            sql = key + montage_sql_value(table=value, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)

            # 执行交易数据
        for k in range(10):
            sql_list_copy = copy(sql_list)
            transactioncfmdate = transactiondate = TransactionDate = '20240826'
            appsheetserialno = AppSheetSerialNo = f"{TransactionDate}{randomInfo.get_random_number(6)}"
            businesscode = BusinessCode = random.choice(['120', '122', '124', '126'])
            applicationvol = ApplicationVol = '0'  # 基金份额数
            applicationamount = ApplicationAmount = randomInfo.get_random_number(random.choice([3, 4, 5, 6, 7]))  # 基金金额
            currencytype = CurrencyType = '156'
            targetsharetype = TargetShareType = 'A'  # 份额类型
            index = random.randint(1, 100)
            Processingstatus = '1'
            taconfirmationnumber = f"{AppSheetSerialNo}{randomInfo.get_random_number(6)}{randomInfo.get_random_number(4)}"
            if index < 10:
                Processingstatus = '0'
                applicationamount = ApplicationAmount = applicationamount + round(random.random(), 2)
            sql_list_copy.update({'taconfirmationnumber': taconfirmationnumber, 'TransactionDate': TransactionDate,
                                  'AppSheetSerialNo': AppSheetSerialNo, 'BusinessCode': BusinessCode,
                                  'ApplicationVol': ApplicationVol, 'ApplicationAmount': ApplicationAmount,
                                  'CurrencyType': CurrencyType, 'TargetShareType': TargetShareType,
                                  'Processingstatus': Processingstatus, 'applicationvol': applicationvol,
                                  'applicationamount': applicationamount, 'appsheetserialno': appsheetserialno,
                                  'transactioncfmdate': transactioncfmdate, 'transactiondate': transactiondate,
                                  'businesscode': businesscode, 'currencytype': currencytype,
                                  'targetsharetype': targetsharetype})
            confirmedamount = ApplicationAmount * 0.95
            confirmedvol = confirmedamount / 1.5  # 后续再捞基金净值算份额
            sharetype = 'A'
            sql_list_copy.update(
                {'confirmedamount': confirmedamount, 'confirmedvol': confirmedvol, 'sharetype': sharetype})
            key_request = get_sql_key(table='taaml_n_request_fund')
            value_request = get_sql(table='taaml_n_request_fund')
            sql = key_request + montage_sql_value(table=value_request, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)
            key = get_sql_key(table='taaml_n_confirm_fund')
            value = get_sql(table='taaml_n_confirm_fund')
            sql = key + montage_sql_value(table=value, sql_list=sql_list_copy)
            db.execsql(sql)
            #pgdb.execsql(sql)


def worker(num):
    print(f'Worker: {num}')
    num = num*10000+400000
    ta_test_person(num,num+10000)
    ta_test_institution(num,num+10000)


if __name__ == '__main__':
    # insert_agencyinfo_his()
    # insert_agencyinfo()
    # insert_fundinfo()
    # exchangerate()
    # insert_fundinfo()
    ta_test_person(startNum, endNum)
    ta_test_institution(startNum, endNum)

    # processes = []
    # for i in range(10):
    #     p = Process(target=worker, args=(i,))
    #     processes.append(p)
    #     p.start()
    #
    # for p in processes:
    #     p.join()